
 
 F u n c t i o n :   i n s e r t M a r k u p ( s t r i n g M a r k u p ,   d o m I n s e r t i o n E l e m e n t ,   s t r i n g P o s i t i o n T o k e n ,   f u n c t i o n C a l l b a c k ( d o m I n s e r t i o n E l e m e n t ) ) 
 
 
 
 D e s c r i p t i o n :   I n s e r t s   a   m a r k u p   s t r i n g   i n t o   a   s p e c i f i e d   t a r g e t   l o c a t i o n   i n   t h e   D O M . 
 
 
 
 R e t u r n s :   d o m E l e m e n t ,   o r   $ A   o b j e c t   i f   c h a i n e d . 
 
 
 
 N o t e :   I f   s t r i n g P o s i t i o n T o k e n   i s   n o t   s e t   t o   a   v a l i d   t o k e n   v a l u e ,   i n n e r H T M L   w i l l   b e   u s e d   i n s t e a d ,   a n d   a l l   p r e e x i s t i n g   c o n t e n t   w i l l   b e   c l e a n e d   a n d   r e m o v e d   t o   p r e v e n t   m e m o r y   l e a k s . 
 
 
 
 A v a i l a b l e   p o s i t i o n   t o k e n s :   " b e f o r e " ,   " a f t e r " ,   " p r e p e n d " ,   o r   " a p p e n d " . 
 
 
 
 E x a m p l e : 
 
 
 
 / /   I n s e r t   a   m a r k u p   s t r i n g   e l e m e n t   a t   t h e   t o p   o f   a n o t h e r   D O M   e l e m e n t 
 
 v a r   m y E l e m e n t   =   $ A . i n s e r t M a r k u p ( ' < d i v > H e r e   w e   a r e   n o w ,   e n t e r t a i n   u s . < / d i v > ' ,   d o m E l e m e n t ,   " p r e p e n d " ) ; 
 
 
 
 / /   I n s e r t   a   m a r k u p   s t r i n g   e l e m e n t   a f t e r   a n o t h e r   D O M   e l e m e n t   a n d   e x i c u t e   a   c a l l b a c k   w h e n   d o n e 
 
 v a r   m y E l e m e n t   =   $ A . i n s e r t M a r k u p ( ' < d i v   r o l e = " t o o l t i p "   i d = " t o o l t i p I d " > Y o u r   E m a i l   a d d r e s s   i s   r e q u i r e d . < / d i v > ' , 
 
 d o m F o r m I n p u t E l e m e n t ,   " a f t e r " ,   f u n c t i o n ( d o m F o r m I n p u t E l e m e n t )   { 
 
     $ A ( d o m F o r m I n p u t E l e m e n t ) . a d d I d R e f e r e n c e ( " a r i a - d e s c r i b e d b y " ,   " t o o l t i p I d " ) . f o c u s ( ) ; 
 
 } ) ; 
 
 
 
 / /   O r   t h e   s a m e   u s i n g   c h a i n i n g 
 
 
 
 / /   I n s e r t   a   m a r k u p   s t r i n g   e l e m e n t   a t   t h e   t o p   o f   a n o t h e r   D O M   e l e m e n t 
 
 v a r   m y C h a i n   =   $ A ( d o m E l e m e n t ) . i n s e r t M a r k u p ( ' < d i v > H e r e   w e   a r e   n o w ,   e n t e r t a i n   u s . < / d i v > ' ,   " p r e p e n d " ) ; 
 
 
 
 / /   I n s e r t   a   m a r k u p   s t r i n g   e l e m e n t   a f t e r   a n o t h e r   D O M   e l e m e n t   a n d   e x i c u t e   a   c a l l b a c k   w h e n   d o n e 
 
 v a r   m y C h a i n   =   $ A ( d o m F o r m I n p u t E l e m e n t ) . i n s e r t M a r k u p ( ' < d i v   r o l e = " t o o l t i p "   i d = " t o o l t i p I d " > Y o u r   E m a i l   a d d r e s s   i s   r e q u i r e d . < / d i v > ' , 
 
 " a f t e r " ,   f u n c t i o n ( d o m F o r m I n p u t E l e m e n t )   { 
 
     $ A ( d o m F o r m I n p u t E l e m e n t ) . a d d I d R e f e r e n c e ( " a r i a - d e s c r i b e d b y " ,   " t o o l t i p I d " ) . f o c u s ( ) ; 
 
 } ) ; 
 
 
 
 / /   T o   r e t u r n   t h e   m o d i f i e d   e l e m e n t   w i t h i n   a   c h a i n ,   u s e   t h e   " r e t u r n ( ) "   m e t h o d . 
 
 
 
 v a r   m y E l e m e n t   =   m y C h a i n . r e t u r n ( ) ; 
 
 